13. Fetch API

Fetch API

1.12 Fetch API Quiz

Instructions

First, if you haven't already, read this and follow the instructions on working with the Exoplanet Explorer repo.

  1. Checkout the fetch-start branch and navigate to app/scripts/app.js.
  2. Rewrite get with the Fetch API: https://davidwalsh.name/fetch
  3. Finish the getJSON() method, which should take a URL and return the parsed JSON response.
    • getJSON() needs to return a Promise!
  4. Test by logging the response and by passing the query string from getJSON() to addSearchHeader().
  5. Handle errors by passing 'unknown' to addSearchHeader() and logging them.

Fetch API Walkthrough

Checkout the fetch-solution branch to see my code.

Solution

1.12 Fetch API Solution